<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="keywords" content="">
  <meta name="description" content="">
  <link href="<?php echo site_url(); ?>favicon.ico" rel="icon" type="image/x-icon" />
  <title>积分比例设置</title>
   <link rel="stylesheet" type="text/css" href="<?php echo site_url(); ?>app/views/css/common.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo site_url(); ?>app/views/js/themes/bootstrap/easyui.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo site_url(); ?>app/views/js/themes/icon.css" />

  <script type="text/javascript" src="<?php echo site_url(); ?>app/views/js/jquery.min.js"></script>
  <script type="text/javascript" src="<?php echo site_url(); ?>app/views/js/jquery.easyui.min.js"></script>
  <script type="text/javascript" src="<?php echo site_url(); ?>app/views/js/locale/easyui-lang-zh_CN.js"></script>

  <script type="text/javascript">
    var url;
    function newPoint(){
      $('#dlg').dialog('open').dialog('setTitle','新增积分项目');
      $('#fm').form('clear');
      url = 'adddb';
    }
    function editPoint(){
      var row = $('#dg').datagrid('getSelected');
      if (row){
        $('#dlgedit').dialog('open').dialog('setTitle','编辑积分项目');
        $('#fmedit').form('load',row);
        url = 'edit?id='+row.id;
      }
    }

    function save_add(){
      $('#fm').form('submit',{
        url: url,
        onSubmit: function(){
          return $(this).form('validate');
        },
        success: function(result){
          var result = eval('('+result+')');
          if (result.success){
            $('#dlg').dialog('close');    // close the dialog
            $('#dg').datagrid('reload');  // reload the user data
          } else {
            $.messager.show({
              title: 'Error',
              msg: result.msg
            });
          }
        }
      });
    }


    function save_edit(){
      $('#fmedit').form('submit',{
        url: url,
        onSubmit: function(){
          return $(this).form('validate');
        },
        success: function(result){
          var result = eval('('+result+')');
          if (result.success){
            $('#dlgedit').dialog('close');    // close the dialog
            $('#dg').datagrid('reload');  // reload the user data
          } else {
            $.messager.show({
              title: 'Error',
              msg: result.msg
            });
          }
        }
      });
    }
    function removePoint(){
      var row = $('#dg').datagrid('getSelected');
      if (row){
        $.messager.confirm('确认','你确定要删除这个积分项目？',function(r){
          if (r){
            $.post('del',{id:row.id},function(result){
              if (result.success){
                $('#dg').datagrid('reload');  // reload the user data
              } else {
                $.messager.show({ // show error message
                  title: 'Error',
                  msg: result.msg
                });
              }
            },'json');
          }
        });
      }
    }
  </script>
</head>
<body>
  <h2 class="navfont">积分比例管理:</h2>


  <table id="dg" title="" class="easyui-datagrid" style="width:1100px;height:550px"
      url="get_point"
      toolbar="#toolbar" pagination="true"
      rownumbers="true" fitColumns="true" singleSelect="true">
    <thead>
      <tr>


        <th field="id" width="50">编号</th> 
        <th field="name" width="50">积分项目</th>
        <th field="change_num" width="50">兑换比例</th>
        <th field="sale" width="50">是否营销员（1：是，0：否）</th>

      </tr>
    </thead>
  </table>
  <div id="toolbar">
    <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newPoint()">新增</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editPoint()">编辑</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removePoint()">删除</a>
  </div>

  <div id="dlg" class="easyui-dialog" style="width:800px;height:350px;padding:10px 20px"
      closed="true" buttons="#dlg-buttons">
    <div class="ftitle"><h4>新增积分比例设置</h4></div>
    <form id="fm" method="post" novalidate>
          <table>

            <tr>
              <td>
  <label>积分项目名称:</label>
              </td>
              <td>
                <div class="fitem">

                  <input name="name"  class="easyui-validatebox" required="true">
                </div>
              </td>
            </tr>


            <tr>
              <td>
  <label>兑换比例:</label>
              </td>
              <td>
                <div class="fitem">

                  <input name="change_num" class="easyui-validatebox" required="true">
                </div>比如1分车险积分兑换10分积分，就填10
              </td>
            </tr>

 <!--            <tr>
              <td>
  <label>联系电话:</label>
              </td>
              <td>
                <div class="fitem">

                  <input name="phone" class="easyui-validatebox" required="true">
                </div>
              </td>
            </tr> -->


            <tr>
              <td>
    <label>积分项目列表:</label>
              </td>
              <td>
                <div class="fitem">

                   <input class="easyui-combotree input-normal control-text" type="text" name="point_list" data-options="url:'<?php  echo site_url();?>index.php/pointlist/get_point_list',method:'get'">
                </div>
              </td>
            </tr>



            <tr>
              <td>
  <label>是否营销员:</label>
              </td>
              <td>
                <div class="fitem">

                       <select  data-rules="{required:true}"  name="sale" class="input-normal">
                          <option value="">请选择...</option>
                                <option value="0">非营销员</option>
                                <option value="1">营销员</option>
                        </select>
                </div>
              </td>
            </tr>
          </table>
    </form>
  </div>



  <div id="dlgedit" class="easyui-dialog" style="width:800px;height:350px;padding:10px 20px"
      closed="true" buttons="#dlg-edit-buttons">
    <div class="ftitle"><h4>编辑积分比例设置</h4></div>
    <form id="fmedit" method="post" novalidate>
          <table>
         <table>

            <tr>
              <td>
  <label>积分项目名称:</label>
              </td>
              <td>
                <div class="fitem">

                  <input name="name" disabled="disabled" class="easyui-validatebox" required="true">
                </div>
              </td>
            </tr>


            <tr>
              <td>
  <label>兑换比例:</label>
              </td>
              <td>
                <div class="fitem">

                  <input name="change_num"  disabled="disabled" class="easyui-validatebox" required="true">
                </div>比如1分车险积分兑换10分积分，就填10
              </td>
            </tr>


            <tr>
              <td>
    <label>积分项目列表:</label>
              </td>
              <td>
                <div class="fitem">

                   <input class="easyui-combotree input-normal control-text" type="text" name="point_list" data-options="url:'<?php  echo site_url();?>index.php/pointlist/get_point_list',method:'get'">
                </div>
              </td>
            </tr>



            <tr>
              <td>
  <label>是否营销员:</label>
              </td>
              <td>
                <div class="fitem">

                       <select  data-rules="{required:true}"  name="sale" class="input-normal">
                          <option value="">请选择...</option>
                                <option value="0">非营销员</option>
                                <option value="1">营销员</option>
                        </select>
                </div>
              </td>
            </tr>
          </table>
    </form>
  </div>

  <div id="dlg-buttons">
    <a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="save_add()">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
  </div>

  <div id="dlg-edit-buttons">
    <a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="save_edit()">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlgedit').dialog('close')">取消</a>
  </div>


</body>
</html>
